package cn.com.dcsgo.controller;

import cn.com.dcsgo.domain.vo.MenuVo;
import cn.com.dcsgo.service.MenuService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * MenuController
 *
 * @author Dcsgo
 * @since 13/5/2025 下午 4:38
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("menu")
@RequiredArgsConstructor
public class MenuController {
    private final MenuService menuService;

    /**
     * 获取所有侧边栏信息
     *
     * @return 所有侧边栏信息
     */
    @GetMapping("sidebar")
    public List<MenuVo> getSidebar() {
        log.debug("MenuController.getSidebar");
        return menuService.getSidebar();
    }

    /**
     * 获取页面组件id
     *
     * @param id 页面id
     * @return 对应组件id
     */
    @GetMapping("{id}/component")
    public Integer getMenuComponentId(@PathVariable Long id) {
        return menuService.getById(id).getComponent();
    }

}
